import { C0LUMNS, DELIVERY_ORDER_C0LUMNS, RECEIVE_C0LUMNS, INVENTORY_COORDINATION } from './index.const';
import ElEditable from '@components/el-editable';
import { IndexService } from './index.service';
const indexService = new IndexService();
export default {
  components: {
    ElEditable
  },
  inject: ['apiMMallWeb'],
  data() {
    return {
      consigneeInfo: {},
      dialogVisible: false,
      C0LUMNS,
      orderDetail: {},
      activeStep: 1,
      orderId: '',
      busModel: 1,
      elStepTitle: ['订单已提交', '订单已通过审核', '订单已确认'],
      activeIndex: 0,
      order_tab: [
        { title: '库存配位', columns: INVENTORY_COORDINATION, tabData: [] },
        { title: '付款信息', tabData: null },
        {
          title: '出库单明细',
          columns: DELIVERY_ORDER_C0LUMNS,
          tabData: [
            {
              orderId: '5087560',
              orderDate: '2020-3-16',
              productId: 'MTA02A',
              pruductName: '11G骨导针',
              pcId: '11256450',
              indate: '2029-01-01',
              count: '7',
              factoryName: '国科恒远(北京)医疗有限公司'
            },
            {
              orderId: '5087560',
              orderDate: '2020-3-16',
              productId: 'MTA02A',
              pruductName: '11G骨导针',
              pcId: '11256450',
              indate: '2029-01-01',
              count: '7',
              factoryName: '国科恒远(北京)医疗有限公司'
            }
          ]
        },
        { title: '配送信息', tabData: null },
        { title: '发票信息', tabData: null },
        {
          title: '收货信息',
          columns: RECEIVE_C0LUMNS,
          tabData: [
            {
              orderId: '5087560',
              orderDate: '2020-3-16',
              productId: 'MTA02A',
              pruductName: '11G骨导针',
              pcId: '11256450',
              indate: '2020-04-01',
              count: '7',
              factoryName: '国科恒远(北京)医疗有限公司'
            }
          ]
        }
      ],
      payload: [],
      appendRelateOrder: []
    };
  },
  async created() {
    this.orderId = this.$route.query.id;
    //根据id获取列表详情
    const detail = await this.apiMMallWeb.OrderDetailOrderV1ApiPOST({
      query: { orderId: this.orderId, page: 0, pageSize: 20 }
    });
    indexService.getTransportName(detail);
    this.orderDetail = detail;
    //获取附加信息
    const data = await this.apiMMallWeb.AppendRelateOrderV1ApiPOST({
      form: { busModel: this.busModel, productLineCode: this.orderDetail.productLineCode }
    });
    this.appendRelateOrder = data;
    //库存配位
    const res = await this.apiMMallWeb.PageListStockBatchOrderV1ApiPOST({
      query: { orderId: this.orderId, page: 0, pageSize: 20 }
    });
    this.order_tab[0].tabData = res.content;
    //收货人信息
    const consigneeInfo = await this.apiMMallWeb.OrderReceiverOrderV1ApiPOST({
      query: { orderId: this.orderId, page: 0, pageSize: 20 }
    });
    this.consigneeInfo = consigneeInfo;
    //订单详情采购产品分页列表
    const pruduct = await this.apiMMallWeb.PageListOrderDetailProductOrderV1ApiPOST({
      query: {
        orderDetailId: this.orderDetail.orderDetailId,
        page: 0,
        pageSize: 0
      }
    });
    this.payload = pruduct.content;
  },
  methods: {
    //添加高亮
    tableRowClassName({ row }) {
      if (row.orderCount > row.inventoryCount) {
        return 'bgHeight';
      }
    },
    showLog() {
      this.dialogVisible = true;
    },
    changeIndex(index) {
      this.activeIndex = index;
    },
    back() {
      this.$router.go(-1);
    }
  }
};
